<template>
	<transition name="modal">
		<div v-if="isVisible" class="modal-overlay">
			<div class="modal-content">
				<span class="modal-close" @click="closeModal" title="关闭模态框">×</span>
				<div class="modal-body">
					<slot></slot>
				</div>
			</div>
		</div>
	</transition>
</template>
<!-- 自定义模态框 -->
<script>
	export default {
		name: 'Modal',
		props: {
			isVisible: {
				type: Boolean,
				required: true
			}
		},
		methods: {
			closeModal() {
				this.$emit('close-modal');
			}
		}
	}
</script>

<style scoped>
	.modal-enter-active,
	.modal-leave-active {
		transition: opacity 0.5s;
	}

	.modal-enter,
	.modal-leave-to {
		opacity: 0;
	}

	.modal-overlay {
		position: fixed;
		/* 		z-index: 9998; */
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background: rgba(0, 0, 0, 0.5);
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.modal-content {
		padding: 20px;
		border-radius: 5px;
		position: relative;
	}

	.modal-close {
		position: absolute;
		z-index: 9999;
		top: 10px;
		right: 20px;
		background: none;
		border: none;
		font-size: 22px;
		cursor: pointer;
	}

	.modal-close:hover {
		color: #777;
	}

	.modal-body {
		/* Add your body styles here */
		background-color: #ffffff;
		opacity: 0.9;
	}
</style>